package com.woniuxy.oa.dao.provider;

import com.woniuxy.oa.entity.Dept;
import com.woniuxy.oa.entity.Meet;
import org.apache.ibatis.jdbc.SQL;

/**
 * @Auther: M
 * @Date: 2019/12/31 15:12
 * @Description:
 */
public class MeetProvider {
    public String getMeetByCondition(Meet meet){
        return new SQL(){
            {
                SELECT("m.*,mr.`description`,mr.`STATUS`,mr.id roodId,e.`email`,e.`phonenum`,e.`STATUS`,e.`NAME`,e.`gender`,e.`LEVEL`,e.id employeeId").FROM("oa_meet m,oa_meetroom mr,oa_employee e").WHERE("m.roomid=mr.id","m.empid=e.id");
                if(meet==null){
                    WHERE("");
                }
                if(meet.getEmp()!=null){
                    if(meet.getEmp().getName()!=null&&meet.getEmp().getName().trim().length()!=0){
                        WHERE("name like concat(\"%\",#{emp.name},\"%\")");
                    }
                }
                if(meet.getRoom()!=null){
                    if(meet.getRoom().getId()!=null&&meet.getRoom().getId().trim().length()!=0){
                        WHERE("rooid=#{room.id}");
                    }
                }
                if(meet.getStartTime()!=null&&meet.getStartTime().trim().length()!=0){
                    WHERE("starttime=#{startTime}");
                }
                if(meet.getEndTime()!=null&&meet.getEndTime().trim().length()!=0){
                    WHERE("endtime=#{endTime}");
                }
            }
        }.toString();
    }
}